/**
 * Created by dell on 2018/12/11.
 */
/*
              restful
 get     http://localhost:3000/books
 get     http://localhost:3000/books/book
 post    http://localhost:3000/books/book
 get     http://localhost:3000/books/book/1
 put     http://localhost:3000/books/book
 delete  http://localhost:3000/books/book/2
 */

const express = require('express');
// 创建一个新的路由器对象
const router = express.Router();
const server = require('./service.js');

// 提供所有的图书信息
router.get('/books',server.allBooks);
// 添加图书信息时提交数据
router.post('/books/book',server.addBook);
// 编辑图书时根据id查询相应信息
router.get('/books/book/:id',server.getBookById);
// 提交编辑的数据
router.put('/books/book',server.editBook);
// 删除图书信息
router.delete('/books/book/:id',server.deleteBook);

module.exports = router;